﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using RussiaLibrary;
namespace Russia
{
    public class Paint
    {
        private Graphics gra;//Graphics：画图类
        public Paint(Panel targetPanel)//Panel targetPanel表示要在哪儿画图形。该项目是在控件panelAll里面画
        {
            gra = targetPanel.CreateGraphics();
        }
        
        public void FillPanel(byte[,] Bytes_TetrisByte)
        {
            for (int x = 0; x < Class_Common.Width; x++)//Class_Common.Width == 10;
             {
                for(int y = 2; y < Class_Common.Length; y++)//前两行用于缓冲
                {
                    if (Bytes_TetrisByte[y, x] == 1)//(int)Polygon_Stament.USED
                    {
                        DrawElement(x, y-2, Color.Red);
                    }else if (Bytes_TetrisByte[y, x] == 2)//(int)Polygon_Stament.NO_USED
                    {
                        DrawElement(x, y-2, Color.Purple);
                    }else{
                        DrawElement(x, y-2, Color.Azure);
                    }
                }
             }
        }
        private void DrawElement(int x, int y, Color color)
        {
            Brush bru = new SolidBrush(color);
            gra.FillRectangle(bru, x * 20, y * 20, 17, 17);
        }
    }
}
